<!--
 * @Author: zhangdong 354266323@qq.com
 * @Date: 2022-06-07 16:56:52
 * @LastEditors: zhangdong 354266323@qq.com
 * @LastEditTime: 2022-06-13 11:59:38
 * @FilePath: \logistics-sunshine-unattended-app\components\C_top\C_top.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <view>
    <u-navbar
      title-color="black"
      back-icon-color="black"
      :is-fixed="isFixed"
      :is-back="isBack"
      :title="title"
      :background="background"
      :back-text-style="{ color: '#fff' }"
      :back-icon-name="backIconName"
    >
      <!-- 右侧图标 -->
      <view class="navbar-right" v-if="rightShow === true" @click="handleClose">
        <view><u-icon name="minus-circle" size="38"></u-icon></view>
      </view>
    </u-navbar>
  </view>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
    },
    rightShow: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      backIconName: 'nav-back',
      rightSlot: false,
      useSlot: false,
      background: {
        'background-image':
          'linear-gradient(45deg, rgb(28, 187, 180), rgb(141, 198, 63))',
        // 'background-color': '#ffffff',
      },
      isBack: true,
      search: false,
      custom: false,
      isFixed: true,
      keyword: '',
      // #ifdef MP
      slotRight: false,
      // #endif
      // #ifndef MP
      slotRight: true,
      // #endif
    }
  },
  methods: {
    handleClose() {
      //退出app
      // #ifdef APP-PLUS
      if (plus.os.name.toLowerCase() === 'android') {
        plus.runtime.quit()
      } else {
        const threadClass = plus.ios.importClass('NSThread')
        const mainThread = plus.ios.invoke(threadClass, 'mainThread')
        plus.ios.invoke(mainThread, 'exit')
      }
      // #endif
    },
  },
}
</script>

<style lang="scss">
.navbar-right {
  margin-right: 24rpx;
  float: right;
  position: absolute;
  right: 0;
}
</style>
